<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
 	<base href="<%=basePath%>">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script type="text/javascript" src="scripts/jquery/jquery-1.7.1.js"></script>
	<link href="style/authority/basic_layout.css" rel="stylesheet" type="text/css">
	<link href="style/authority/common_style.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="scripts/authority/commonAll.js"></script>
	<script type="text/javascript" src="scripts/fancybox/jquery.fancybox-1.3.4.js"></script>
	<script type="text/javascript" src="scripts/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
	<link rel="stylesheet" type="text/css" href="style/authority/jquery.fancybox-1.3.4.css" media="screen"></link>
	<script type="text/javascript" src="scripts/artDialog/artDialog.js?skin=default"></script>
    
    
    <title>添加供应商</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript">
		function checksupplier_name(){
			var st = document.getElementById("supplier_name").value;
			if(st==""){document.getElementById("supplier_name_lab").innerHTML="<font color='red'>供应商不能为空</font>"; return false;}
			else{
				document.getElementById("supplier_name_lab").innerHTML="";
				return true;
			}
		}
		function checksupplier_address(){
			var st = document.getElementById("supplier_address").value;
			if(st==""){document.getElementById("supplier_address_lab").innerHTML="<font color='red'>地址不能为空</font>"; return false;}
			else{
				document.getElementById("supplier_address_lab").innerHTML="";
				return true;
			}
		}
		function checksupplier_linkman()
		{
			var st = document.getElementById("supplier_linkman").value;
			if(st==""){document.getElementById("supplier_linkman_lab").innerHTML="<font color='red'>联系人不能为空</font>"; return false;}
			else{
				document.getElementById("supplier_linkman_lab").innerHTML="";
				return true;
			}
		}
		function checksupplier_tel(){
			var st = document.getElementById("supplier_tel").value;
			if(st=="") {document.getElementById("supplier_tel_lab").innerHTML="<font color='red'>联系电话不能为空</font>"; return false;}
			else{
				var reg = new RegExp("^([0-9]{3,4}-)?[0-9]{8}$");
				var ans=true;
				ans = reg.test(st);
				//alert(reg.test(st));
				if(ans)	{document.getElementById("supplier_tel_lab").innerHTML="";return true;}
				else {document.getElementById("supplier_tel_lab").innerHTML="<font color='red'>非法输入</font>"; return false;}
			}
		}
		function checksupplier_bank_name()
		{
			var st = document.getElementById("supplier_bank_name").value;
			if(st==""){document.getElementById("supplier_bank_name_lab").innerHTML="<font color='red'>开户行不能为空</font>"; return false;}
			else{
				document.getElementById("supplier_bank_name_lab").innerHTML="";
				return true;
			}
		}
		function checksupplier_bank_account(){
			var st = document.getElementById("supplier_bank_account").value;
			if(st=="") {document.getElementById("supplier_bank_account_lab").innerHTML="<font color='red'>银行账户不能为空</font>"; return false;}
			else{
				var reg = new RegExp("^[0-9]{16}|[0-9]{19}$");
				var ans=true;
				ans = reg.test(st);
				//alert(reg.test(st));
				if(ans)	{document.getElementById("supplier_bank_account_lab").innerHTML="";return true;}
				else {document.getElementById("supplier_bank_account_lab").innerHTML="<font color='red'>非法输入</font>"; return false;}
			}
		}
		function checksupplier_fax(){
			var st = document.getElementById("supplier_fax").value;
			if(st=="") {document.getElementById("supplier_fax_lab").innerHTML="<font color='red'>传真不能为空</font>"; return false;}
			else{
				var reg = new RegExp("^([0-9]{3,4}-)?[0-9]{8}$");
				var ans=true;
				ans = reg.test(st);
				//alert(reg.test(st));
				if(ans)	{document.getElementById("supplier_fax_lab").innerHTML="";return true;}
				else {document.getElementById("supplier_fax_lab").innerHTML="<font color='red'>非法输入</font>"; return false;}
			}
		}
		function checksupplier_zipcode(){
			var st = document.getElementById("supplier_zipcode").value;
			if(st=="") {document.getElementById("supplier_zipcode_lab").innerHTML="<font color='red'>邮编不能为空</font>"; return false;}
			else{
				var reg = new RegExp("^[1-9][0-9]{5}$");
				var ans=true;
				ans = reg.test(st);
				//alert(reg.test(st));
				if(ans)	{document.getElementById("supplier_zipcode_lab").innerHTML="";return true;}
				else {document.getElementById("supplier_zipcode_lab").innerHTML="<font color='red'>非法输入</font>"; return false;}
			}
		}
		function checksupplier_corporation(){
			var st = document.getElementById("supplier_corporation").value;
			if(st==""){document.getElementById("supplier_corporation_lab").innerHTML="<font color='red'>法人不能为空</font>"; return false;}
			else{
				document.getElementById("supplier_corporation_lab").innerHTML="";
				return true;
			}
		}
		function checkall()
		{
			if(!checksupplier_name()) return;
			if(!checksupplier_address()) return;
			if(!checksupplier_linkman()) return;
			if(!checksupplier_tel()) return;
			if(!checksupplier_bank_name()) return;
			if(!checksupplier_bank_account()) return;
			if(!checksupplier_fax()) return;
			if(!checksupplier_zipcode()) return;
			if(!checksupplier_corporation()) return;
			document.form1.submit();
		}
	</script>
  </head>
  
  <body>
  	<div id="container">	
		<div class="ui_content">
			<div class="ui_tb">
			    <form name="form1" action="servlet/Newsupplierservlet?type=insert" method="post">
			    	<table class="table" width="100%" align="center">
			    		<tr>
			    			<th width="15%">供应商名</th>
			    			<td width="35%"><input class="ui_input_txt02" id="supplier_name" value="${updatesupplier==null?'':updatesupplier.name}" name="supplier_name" type="text" onblur="checksupplier_name()"/><label id ="supplier_name_lab" ></label></td>
			    			<th width="15%">地址</th>   
							<td width="35%"><input class="ui_input_txt02" id="supplier_address" value="${updatesupplier==null?'':updatesupplier.address}" name="supplier_address" type="text" onblur="checksupplier_address()"/><label id ="supplier_address_lab" ></label></td>			
			    		</tr>
			    		<tr>
			    			<th width="15%">联系人</th>
			    			<td width="35%"><input class="ui_input_txt02" id="supplier_linkman" value="${updatesupplier==null?'':updatesupplier.linkman}" name="supplier_linkman" type="text" onblur="checksupplier_linkman()"/><label id ="supplier_linkman_lab" ></label></td>
			    			<th width="15%">联系电话</th>   
							<td width="35%"><input class="ui_input_txt02" id="supplier_tel" value="${updatesupplier==null?'':updatesupplier.tel}" name="supplier_tel" type="text" onblur="checksupplier_tel()"/><label id ="supplier_tel_lab" ></label></td>			
			    		</tr>
			    		<tr>
			    			<th width="15%">开户行</th>
			    			<td width="35%"><input class="ui_input_txt02" id="supplier_bank_name" value="${updatesupplier==null?'':updatesupplier.bank_name}" name="supplier_bank_name" type="text" onblur="checksupplier_bank_name()"/><label id ="supplier_bank_name_lab" ></label></td>
			    			<th width="15%">银行账号</th>
							<td width="35%"><input class="ui_input_txt02" id="supplier_bank_account" value="${updatesupplier==null?'':updatesupplier.bank_account}" name="supplier_bank_account" type="text" onblur="checksupplier_bank_account()"/><label id ="supplier_bank_account_lab" ></label></td>			
			    		</tr>
			    		<tr>
			    			<th width="15%">传真</th>
			    			<td width="35%"><input class="ui_input_txt02" id="supplier_fax" value="${updatesupplier==null?'':updatesupplier.fax}" name="supplier_fax" type="text" onblur="checksupplier_fax()"/><label id ="supplier_fax_lab"></label></td>
			    			<th width="15%">邮编</th>   
							<td width="35%"><input class="ui_input_txt02" id="supplier_zipcode" value="${updatesupplier==null?'':updatesupplier.zipcode}" name="supplier_zipcode" type="text" onblur="checksupplier_zipcode()"/><label id ="supplier_zipcode_lab" ></label></td>			
			    		</tr>
			    		<tr>
			    			<th width="15%">法人</th>
			    			<td width="35%"><input class="ui_input_txt02" id="supplier_corporation" value="${updatesupplier==null?'':updatesupplier.corporation}" name="supplier_corporation" type="text" onblur="checksupplier_corporation()"/><label id ="supplier_corporation_lab" ></label></td>
			    			<th width="15%">备注</th>   
							<td width="35%"><input class="ui_input_txt02" id="supplier_tips" value="${updatesupplier==null?'':updatesupplier.tips}" name="supplier_tips" type="text"/></td>			
			    		</tr>   
			    		<tr>
			    			<td colspan="2" align="center"><input class="ui_input_btn01" value="重置" type="reset"/></td>
			    			<td colspan="2" align="center"><input class="ui_input_btn01" value="提交" type="button" onclick="checkall()"/></td>
			    		</tr>   		
			    	</table>
			    	<input name="update_name" value="${updatesupplier==null?'new':updatesupplier.name}" type="hidden">
			    </form>
			</div>
		</div>
	</div>
  </body>
</html>
